/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Client;

/**
 *
 * @author DucAnh
 */
import java.net.*;
import java.io.*;
import java.sql.*;
import java.util.*;
import java.lang.*;
import javax.swing.*;  
import java.awt.*;  
import java.awt.event.*;  
import java.io.EOFException;

public class Client extends javax.swing.JFrame {
public String str12=""; // ma tour da chon
public String str13=""; // ma khach san da chon
public String comtour;
public String hovaten;
public String sohochieu;
public String scmnd;
public String diachi;
public String dienthoai;
public String email;
public String sove;

public String chonchucnangchuongtrinh;
    /** Creates new form JFrame */
    public Client() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

		install_component(); // khoi tao cac component trong frame
		
        jLabel17.setFont(new java.awt.Font("Times New Roman", 1, 20));
        jLabel17.setText("WELLCOME TO DA NANG TOURIS");
        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18));
        jLabel1.setText("THONG TIN DANG KY TOUR DU LICH");
        jLabel3.setText("Ten");
        jLabel4.setText("Dia chi");    
        jLabel5.setText("SDT");
        jLabel6.setText("Email");
        jLabel7.setText("Chon Tour");
        
        // ------------------------------------------------------------------//
        // ------------------------XU LY SU KIEN KHI CHON TOUR---------------//
        // ------------------------------------------------------------------//
       	jComboBox2_disPlay();
       	
        str12=((tour)jComboBox2.getItemAt(0)).get_id();
        
		//---------------------HIEN THI CAC THONG TIN VE KHACH SAN, PHUONG TIEN DI CHUYEN CUA TOUR DA CHON -------//
		jComboBox2.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent evt) {
            try{
               str12=((tour)jComboBox2.getSelectedItem()).get_id();  // lay thong tin ve ID cua tour
	           jComboBox3_disPlay();
	           jComboBox5_disPlay();
            }
            catch(Exception e3){
			e3.printStackTrace();
		}
               
            }
        });
		
       jLabel8.setText("Khach san");
       	//----------------------HIEN THI KHACH SAN LAN DAU TIEN ------------
       	jComboBox3_disPlay();
        //jLabel10.setText("So phong");
        jLabel11.setText("Phuong tien");
        //---------------------HIEN THI PHUONG TIEN DI CHUYEN LAN DAU TIEN -------------------//
		jComboBox5_disPlay();
        
        jLabel12.setText("So ve");
        jLabel13.setText("CMND");
        jLabel14.setText("Ho chieu");
        //jLabel16.setText("CHUC NANG");
        //jComboBox6.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Dang ky", "Xoa", "Cap Nhat" }));
        jButton1.setText("Dang ki");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
      
        
// --------------------------------------------------------------------//        
// --------------------- Ve cac component cua chuong trinh ------------------------//
// --------------------------------------------------------------------//
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        // Xac dinh toa do chieu ngang
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap())
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE))
						.addGroup(layout.createSequentialGroup()
							.addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE)
                        
							)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel6)
                                .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel13)
                                // Ten
                                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    // Dia chi
                                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE))
                                .addComponent(jLabel5))
                            .addGap(18, 18, 18)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextField7, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                                .addComponent(jTextField8, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                                //.addComponent(jComboBox1, 0, 262, Short.MAX_VALUE)
                                .addComponent(jTextField6, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                                .addComponent(jComboBox5, 0, 192, Short.MAX_VALUE)
                                //.addComponent(jTextField5, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
                                .addComponent(jComboBox3, 0, 192, Short.MAX_VALUE)
                                .addComponent(jComboBox2, 0, 192, Short.MAX_VALUE)
                                .addComponent(jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                                .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                                .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                                .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                                //.addComponent(jComboBox6, 0, 262, Short.MAX_VALUE)
                                )
                                
                            .addGap(34, 34, 34)
                            //.addComponent(jButton2)
                            .addComponent(jButton1)
                             .addGap(63, 63, 63)
                            )
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            //.addComponent(jLabel10, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.LEADING)))))
        );
        
        // Xac dinh toa do chieu doc
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(50, 50, 50)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(90, 90, 90)
                        .addComponent(jLabel15)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                //.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    //.addComponent(jLabel2)
                    //.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                  //  )
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1)
                    )
                .addGap(5, 5, 5)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                   // .addComponent(jButton2)
                    )
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel13)
                    .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                   )
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                /*
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                */    
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel11)
                    .addComponent(jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12)
                    .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                  //  .addComponent(jLabel16)
                    //.addComponent(jComboBox6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                		)
                .addContainerGap(13, Short.MAX_VALUE))
        );

        pack();

// -----------------------------------------------------//
// -----------------------------------------------------//        
        
    }// </editor-fold>
    
    
private void install_component()    
{
	jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();  // ten
        jTextField2 = new javax.swing.JTextField();  // dia chi
        jLabel5 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();  // passport
        jLabel6 = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();  // cmnd
        jLabel7 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        jComboBox3 = new javax.swing.JComboBox();
    	//jLabel10 = new javax.swing.JLabel();
        //jTextField5 = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jComboBox5 = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        jTextField6 = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jTextField7 = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jTextField8 = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jComboBox6 = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
		jLabel17 = new javax.swing.JLabel();
		
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setFocusCycleRoot(false);
        
}

	// hien thi danh sach cac tour
	private void jComboBox2_disPlay()
 	{
 		jComboBox2.setModel(new javax.swing.DefaultComboBoxModel());
		
		try{
			 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
			 String url3 = "jdbc:odbc:TOUR";
			 Connection dbcn3 = DriverManager.getConnection(url3);
			 Statement dbst3 = dbcn3.createStatement();
     		 ResultSet rs3=null;
	  		 rs3 = dbst3.executeQuery("select distinct tour,tour_name from tour");
			 while (rs3.next()) {
				String tour_id=rs3.getString(1);
				String tour_name=rs3.getString(2);
				tour _tour = new tour(tour_id,tour_name);
				jComboBox2.addItem(_tour);
			}
		}catch(Exception e3){
			e3.printStackTrace();
		}
 	}
    
	// Hien thi khach san cua tour du lich da chon
    private	void jComboBox3_disPlay()
    {   jComboBox3.setModel(new javax.swing.DefaultComboBoxModel());
        
		try{
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
			String url4 = "jdbc:odbc:TOUR";
			Connection dbcn4 = DriverManager.getConnection(url4);
			
	  		ResultSet rs4=null;
	  		PreparedStatement dbrst4 = dbcn4.prepareStatement("select distinct tour.tour,tour.khachsan,mota from tour, khachsan where tour.khachsan = khachsan.khachsan and tour.tour = ?");
	  		dbrst4.setString(1,str12);
	  		rs4 = dbrst4.executeQuery();
	  		
	  		while (rs4.next()) {
				String tam4=rs4.getString(2);
				String tam4_2=rs4.getString(3);
				jComboBox3.addItem(new hotel(tam4,tam4_2));
			}
	  		
	  		
		}catch(Exception e4){
			e4.printStackTrace();
		}	 
    }
    // Hien thi phuong tien di lai cua tour du lich da chon
    private void jComboBox5_disPlay()
    {
    	jComboBox5.setModel(new javax.swing.DefaultComboBoxModel()); //Dinh dang du lieu vao combo
		try{
			 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
			 String url5 = "jdbc:odbc:TOUR";
			 Connection dbcn5 = DriverManager.getConnection(url5);
			 
			 ResultSet rs5=null;
	  		PreparedStatement dbrst5 = dbcn5.prepareStatement("select distinct tour.phuongtien from tour, phuongtien where tour.phuongtien = phuongtien.phuongtien and tour.tour = ? ");
	  		dbrst5.setString(1,str12);
	  		
	  		rs5 = dbrst5.executeQuery();
			
			while (rs5.next()) {
				String tam5=rs5.getString(1);
				jComboBox5.addItem(tam5);
			}
		}catch(Exception e5){

		}
    }
 
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    	hovaten=jTextField1.getText();
    	sohochieu=jTextField8.getText();
        scmnd=jTextField7.getText();
        diachi=jTextField2.getText();
		dienthoai=jTextField3.getText();
		email=jTextField4.getText();
        comtour=((tour)jComboBox2.getSelectedItem()).get_id();
		sove=jTextField6.getText();
				
		if (! isValidateData())
		{
			return;
		}

        try
		{
			Client_Connect_2_Server client = new Client_Connect_2_Server("localhost",2001);
			client.requestServer();
			client.shutdown();
		}
		catch (Exception e1)
		{
			jLabel15.setText("Server hien dang qua tai, ban lui long dang ki sau 1 phut nua !");
		}
	}
    
    public boolean isValidateData()
    {
    	
    		
    	// Kiem tra Ho va ten
    	if( hovaten.compareTo("") == 0 )
    	{
    		jLabel15.setText("Ban chua nhap Ho va Ten !" ); 
    		return false;
    	}
    	
    	for(int i=0; i<hovaten.length(); i++)
    	{
    		if(hovaten.charAt(i)=='|')
    		{
    			jLabel15.setText("Ho va Ten khong duoc chua ki tu '|'. Ban nen thay bang ki tu trang !" );
    			return false;
    		}
    	}
    	// neu chieu dai ho ten dai qua 255 ki tu, chi lay 255 ki tu
    	if(hovaten.length() >= 256)
    	{
    		hovaten=hovaten.substring(0, 255);
    		jTextField1.setText(hovaten);
    	}
    	// Kiem tra So ho chieu hoac so cmnd
    	if( (sohochieu.compareTo("") == 0) && (scmnd.compareTo("") == 0) )
    	{
    		
    		jLabel15.setText("Ban chua nhap so ho chieu hoac CMND !"); 
    		return false;
    	}
    	
    	for(int i=0; i<sohochieu.length(); i++)
    	{
    		if(sohochieu.charAt(i)=='|')
    		{
    			jLabel15.setText("So Ho Chieu khong duoc chua ki tu '|'. Ban nen thay bang ki tu trang !" );
    			return false;
    		}
    	}
    	
    	for(int i=0; i<scmnd.length(); i++)
    	{
    		if(scmnd.charAt(i)=='|')
    		{
    			jLabel15.setText("So CMND khong duoc chua ki tu '|'. Ban nen thay bang ki tu trang !" );
    			return false;
    		}
    	}
    	
    	if(sohochieu.length() >= 256)
    	{
    		sohochieu=sohochieu.substring(0, 255);
    		jTextField8.setText(sohochieu);
    	}

    	if(scmnd.length() >= 10)
    	{
    		scmnd=scmnd.substring(0, 9);
    		jTextField7.setText(scmnd);
    	}
    	
    	// Kiem tra email
    	if(email.compareTo("") == 0) 
    	{
    		jLabel15.setText("Ban chua nhap Email !"); 
    		return false;
    	}
    	if(email.length() >= 51)
    	{
    		email=email.substring(0, 50);
    		jTextField4.setText(email);
    	}
    	for(int i=0; i<email.length(); i++)
    	{
    		if(email.charAt(i)=='|')
    		{
    			jLabel15.setText("Email khong duoc chua ki tu '|'. Ban nen thay bang ki tu trang !" );
    			return false;
    		}
    	}
    	
    	// Kiem tra dia chi
    	if( diachi.compareTo("") == 0 )
    	{
    		jLabel15.setText("Ban chua nhap dia chi !"); 
    		return false;
    	}
    	
    	for(int i=0; i<diachi.length(); i++)
    	{
    		if(diachi.charAt(i)=='|')
    		{
    			jLabel15.setText("Dia chi khong duoc chua ki tu '|'. Ban nen thay bang ki tu trang !" );
    			return false;
    		}
    	}
    	if(diachi.length() >= 256)
    	{
    		diachi=diachi.substring(0, 255);
    		jTextField2.setText(diachi);
    	}
    	
    	// Kiem tra dien thoai
    	if( dienthoai.compareTo("") == 0 )
    	{
    		jLabel15.setText("Ban chua nhap so dien thoai !"); 
    		return false;
    	}
    	
    	for(int i=0; i<dienthoai.length(); i++)
    	{
    		if(dienthoai.charAt(i)=='|')
    		{
    			jLabel15.setText("So dien thoai khong duoc chua ki tu '|'. Ban nen thay bang ki tu trang !" );
    			return false;
    		}
    	}
    	
    	if(dienthoai.length() >= 10)
    	{
    		dienthoai=dienthoai.substring(0, 9);
    		jTextField3.setText(dienthoai);
    	}
    	
    	
    	
    	// Kiem tra da nhap so ghe chua
    	if( sove.compareTo("") == 0 )
    	{
    		jLabel15.setText("Ban chua nhap so ghe !"); 
    		return false;
    	}
    	else
    	{
    		// Kiem tra so ve phai la 1 so nguyen
	    	try { 
	    		int intSove =  Integer.parseInt(sove);
	    		
	        } 
	    	catch( Exception   ex)
	    	{	
	    		jLabel15.setText("So ve phai la 1 so nguyen");
	    		return false ;
	    	}  
    	}
    	
		return true;

    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Client().setVisible(true);
            }
        });
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++
		//++
		
		// Tao 1 server socket de nhan thong diep phan hoi tu Server1, sau khi server 1 cap nhat csdl
        // --------------------------------------
		// --
		
		try
		{
		   ServerSocket server = new ServerSocket(2000); 
		   while(true)
		   {
			   //tao 1 socket do ket noi tu client toi server 
			   Socket connectionSocket = server.accept(); 
				
			   //tao luong nhan du lieu tu client
			   DataInputStream inFromClient = new DataInputStream(connectionSocket.getInputStream());
			   // tao luong gui du lieu toi client
			   DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream()); 
			   
			   // Truyen du lieu tra ve tu server 1 qua bien result
			   String result = inFromClient.readLine(); 
			   
			   // Thong bao cho nguoi dung ket qua dang ki
			   jLabel15.setText(result);
			   
			   //server.close(); 
		   }
		   
		}
		catch(IOException e)
		{
			System.out.println("<<<<<Loi khong the tao Server>>>>>\n"+e);
		}
   
       
    }
    class Client_Connect_2_Server {
    Socket connection;
    DataOutputStream out;
    BufferedReader in;
	public Client_Connect_2_Server(String destination,int port)
	{
  		try
  		{
  			connection = new Socket(destination,port);
  			in = new BufferedReader(new
  			InputStreamReader(connection.getInputStream()));
  			out= new DataOutputStream(connection.getOutputStream());
  			
                        jLabel15.setText("\u0110\u00e3 k\u1ebft n\u1ed1i t\u1edbi c\u1ed5ng 3456.");
  		}
  		catch(Exception e)
  		{
  			jLabel15.setText("L\u1ed7i k\u1ebft n\u1ed1i \u0111\u1ebfn m\u00e1y ch\u1ee7:");
                       
  		}
 	}
    public void requestServer()
	{
		BufferedReader keyboardInput = new BufferedReader(
                     new InputStreamReader(System.in));

        boolean finished=false;
        //do
        {
        	try
        	{
								
        		String thongdiep =hovaten+"|"+sohochieu+"|"+scmnd+"|"+diachi+"|"+dienthoai+"|"+email+"|"+comtour+"|"+sove;
        		out.writeBytes("@$0|000|145|Client|Send|1|123$$"+thongdiep+"$@");
        		out.write(13);
        		out.write(10);
        		out.flush();

        		int inByte;
        		System.out.print(thongdiep);
        		while ((inByte = in.read()) != '\n')
                            System.out.write(inByte);
        		//System.out.println();

        	}
        	catch(Exception e)
        	{
        		jLabel15.setText("L\u1ed7i y\u00eau c\u1ea7u m\u00e1y ch\u1ee7:");
        	}
        }
        //while(!finished);
     }

    public void shutdown()
 	{
  		try
  		{
    		connection.close();
    	}
    	catch(IOException ex)
    	{
    		jLabel15.setText("IO error closing socket");
    	}
    }
    
    
}


    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    //private javax.swing.JComboBox jComboBox4;
    private javax.swing.JComboBox jComboBox5;
    private javax.swing.JComboBox jComboBox6;
    private javax.swing.JLabel jLabel1;
    //private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private static javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
	private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    //private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    //private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JTextField jTextField8;
    
    // End of variables declaration

}
class tour
{
	private String tour_id="";
	private String tour_name="";
	public tour(String id,String name) {
        this.tour_id=id;
        this.tour_name=name;
    }
    public String get_id(){
    	return tour_id;
    }
    public String get_name(){
    	return tour_name;
    }
	@Override 
		public String toString() {
			return tour_name;
		}
}

class hotel
{
	private String id="";
	private String name="";
	public hotel(String id,String name) {
        this.id=id;
        this.name=name;
    }
    public String get_id(){
    	return id;
    }
    public String get_name(){
    	return name;
    }
	@Override 
		public String toString() {
			return name;
		}
}